#!/bin/bash

source  /home/pi/.bashrc

MONTH=$(date +"%m")
DAY=$(date +"%d")
YEAR=$(date +"%Y")
ONE=1
YDAY="$(($DAY-$ONE))"
DAYNAME=$(date +"%A")

TIME=$(date +%k%M)
date

echo $DAYNAME
echo $TIME

cd /home/pi/thumbnailPage/old/
mkdir  $DAYNAME-$YEAR$MONTH$DAY
/bin/mv /home/pi/motion/*-$YEAR$MONTH$DAY*.jpg  /home/pi/thumbnailPage/old/$DAYNAME-$YEAR$MONTH$DAY

cd /home/pi/thumbnailPage/old/$DAYNAME-$YEAR$MONTH$DAY
/home/pi/thumbnailPage/scale-make  *-$YEAR$MONTH$DAY*.jpg
/bin/mv   i.html  index.html
pwd

echo 0 > /home/pi/count_motion

if [[ "$TIME" -eq 2330 ]] ;then
     mkdir  $DAYNAME-$YEAR$MONTH$DAY

else
     echo "not time yet"
fi


if [[ "$TIME" -eq 2330 ]] ;then
     mkdir  $DAYNAME-$YEAR$MONTH$DAY

else
     echo "not time yet"
fi


